package info.rflow.model;

import info.rflow.Utils;

import java.util.ArrayList;


/**
 * Document me!
 *
 * @author Holger Brandl
 */
public class BlockExecutionScheduler extends Thread {

    private ArrayList<RBlock> execSchedule;


    public BlockExecutionScheduler(ArrayList<RBlock> execSchedule) {
        this.execSchedule = execSchedule;
    }


    @Override
    public void run() {
        super.run();

        for (RBlock rBlock : execSchedule) {
            Utils.log("executing " + rBlock);
            rBlock.execute();
        }

        if (execSchedule.size() > 0) {
            execSchedule.get(0).getWorkflowModel().getOutputCache().save();
        }

        Utils.log("finished block queue execution");
    }
}
